<template>
  <div>
    <h2 @click="click(2)">我是子组件二</h2>
    <div>
      <h2>天道酬勤</h2>
      <h3>未来可期</h3>
    </div>

    <button @click="changeWord">事件总线 去修改组件one的word</button>
    <button @click="emitEvent">自定义事件去修改父组件的price</button>
    <button @click="changePrice">$parent 去修改父组件的price</button>

    <div>
      <slot>如果没有数据就显示这里</slot>
    </div>

    <div>
      <slot name="demo"> Demo - demo - 呆毛 </slot>
    </div>
  </div>
</template>

<script>
export default {
  props: ["click"],
  methods: {
    changeWord() {
      this.$bus.$emit("changeByBus", "dayUp - 未来可期");
    },
    changePrice() {
      this.$parent.price += 20;
    },
    emitEvent() {
      this.$emit("changePrice", 30);
    },
  },
};
</script>